package com.db.patterns.prototype.demo02;


import lombok.extern.slf4j.Slf4j;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

@Slf4j
public class Client {
    public static void main(String[] args) throws Exception {
        Resume resume1 = new Resume();
        resume1.setName("小兵");
        resume1.setAge(25);
        resume1.setGender("男");
        resume1.setWorkExperience(new WorkExperience("2023-2024", "北京xxx公司任职Java开发工程师"));

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("resume.txt"));
        oos.writeObject(resume1);
        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("resume.txt"));
        Resume resume2 = (Resume) ois.readObject();
        WorkExperience workExperience = resume2.getWorkExperience();
        workExperience.setCompany("深圳xxxx医疗公司任职Java开发工程师");
        log.info("resume1 = {}", resume1);
        log.info("resume2 = {}", resume2);
        log.info("resume1 == resume2 ? {} ", (resume1 == resume2));
        ois.close();
    }
}
